<?php

defined('_JEXEC') or die('Restricted access');
function report_month_soon($month)
       {       
            $db = JFactory::getDBO();
            if($_SESSION['id_a_b']==0)
        {
            $sql = "select pf.id_employee, us.name, ts.Time, ws.outtime, us.id, ab.id_a_b, ts.type_in_out, ts.id
                                FROM #__erp_employee_profile pf
                                LEFT JOIN #__erp_agent_branch_user ab
        	                    ON pf.id = ab.id_user
                                INNER JOIN #__users us
                                on pf.id = us.id
                                INNER JOIN #__erp_timesheet ts
                                on pf.id = ts.id_user
                                INNER JOIN #__erp_employee_workshifts ws
                                ON ws.id = pf.id_work_shifts  
                                Where month(ts.Time) = '".$month."'
                                and ts.type_in_out = 1
                                order by us.id desc, ts.time desc
                            ";
            $db->setQuery($sql);
        }
        else
        {
            $sql = "select pf.id_employee, us.name, ts.Time, ws.outtime, us.id, ab.id_a_b, ts.type_in_out, ts.id
                                FROM #__erp_employee_profile pf
                                LEFT JOIN #__erp_agent_branch_user ab
        	                    ON pf.id = ab.id_user
                                INNER JOIN #__users us
                                on pf.id = us.id
                                INNER JOIN #__erp_timesheet ts
                                on pf.id = ts.id_user
                                INNER JOIN #__erp_employee_workshifts ws
                                ON ws.id = pf.id_work_shifts  
                                 Where month(ts.Time) = '".$month."'
                                and ab.id_a_b = '".$_SESSION['id_a_b']."'
                                and ts.type_in_out = 1
                                order by us.id desc, ts.time desc
                            ";
            $db->setQuery($sql);
       }
       return $db->loadObjectList(); 
       }
?>